//
//  AnnuaireAppDelegate.m
//  Annuaire
//
//  Created by Jordan SARRE MOLINES on 04/12/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "AnnuaireAppDelegate.h"
#import "Contact.h"
@implementation AnnuaireAppDelegate

@synthesize tableView;
@synthesize textView;
@synthesize window;
@synthesize text;
@synthesize array;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSLog(@"applicationDidFinishLaunching");
    array = [NSMutableArray alloc];
    
    Contact * contact= nil;
    
    contact = [[Contact alloc] init];
    contact.prenom = @"Paul";
    contact.nom = @"Bonhomme";
    
    [array addObject: contact];
    [contact autorelease];
    
    contact = [[Contact alloc] init];
    contact.prenom = @"Pierre";
    contact.nom = @"Marchefeu";
    
    [array addObject: contact];
    [contact autorelease];
    
    contact = [[Contact alloc] init];
    contact.prenom = @"Jean";
    contact.nom = @"Silvestre";
    
    [array addObject: contact];
    [contact autorelease];

    [text setEditable:false];
    
    [self refresh];
}


-(void) refresh {

    [text setStringValue:@""];
    for (Contact *contact in array) {
        
        NSString *str = [[NSString alloc] initWithFormat:@"%@%@ %@\n",text.stringValue, contact.prenom, contact.nom];
        
        [text setStringValue:str];
        [str autorelease];
    }
}

- (IBAction)add:(id)sender {
}

- (IBAction)delete:(id)sender {
}
- (IBAction)searching:(id)sender {
}
@end
